{% extends 'PHPDishWebBundle::layout.html.twig' %}

{% set title = post is defined ? '编辑文章' : '创作文章' %}
{% block title %} {{ title }} {% endblock %}

{% block script %}
<script type="text/javascript" src="{{ asset('build/js/post.js') }}"></script>
{% endblock %}

{% block content %}
<div class="container narrow-layout">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-u add-post">
                <div class="panel-heading">{{ title }}</div>
                <div class="panel-body">
                    {{ form_start(form, {'attr': {'id': 'add-post-form'}}) }}
                    {{ form_errors(form) }}
                    <div class="form-group">
                        {{ form_widget(form.title, {'attr': {'class': 'form-control', 'placeholder': '请输入文章标题'}}) }}
                        {{ form_errors(form.title) }}
                    </div>
                    <div class="form-group">
                        {{ form_widget(form.originalBody, {'required': false, 'attr': {
                            'class': 'form-control body',
                            'placeholder': "请使用 Markdown 格式书写,注意代码高亮。" }}
                        ) }}
                        {{ form_errors(form.originalBody) }}
                    </div>
                    <div class="form-group">
                        {{ form_widget(form.category, {'attr': {'class': 'selectpicker form-control category'}}) }}
                        {{ form_errors(form.category) }}
                    </div>
                    {{ form_end(form) }}
                </div>
            </div>
        </div>
    </div>
</div>

<div class="action-popover">
    <div class="container narrow-layout">
        <button type="submit" form="add-post-form" data-action="add-post" class="btn u-btn-primary pull-right"><i class="if i-publish"></i> 发布</button>
    </div>
</div>
{% endblock %}

{% block footer %}
{% endblock %}